import { Injectable } from '@angular/core';
import { HttpClient } from '../../providers/httpClient';
import { Config } from '../../providers/config';

@Injectable()
export class TodoService {
	constructor(
		public httpClient: HttpClient,
		public config: Config
	) { }
	getListData(page, type, isShowLoading) {
		let postBody;
		if (type == 'inbox') {
			postBody = {
				"module": "Email",
				"method": "getMailInfByCondition",
				"params": {
					"listType": "IMailInbox",
					"bostitle": null,
					"sendAccount": null,
					"recipients": null,
					"bDate": null,
					"eDate": null,
					"opraterLogid": "fengjk",
					"orderField": "mailbosid",
					"orderDirect": null,
					"page": page,
					"pageSize": this.config.pageSize
				}
			};
		} else {
			postBody = {
				"module": "OAServer",
				"method": "getTaskWkiDtoList",
				"params":{
			        "loginId": "",
			        "page": page,
			        "pageSize": this.config.pageSize,
			        "wkiType": "2"
				}
			};
		}
		return this.httpClient.post(postBody,{
			isShowLoading: isShowLoading
		});
	}

  /**
   * [getUSPAthority 获取员工权限]
   * @param
   */
  getUSPAthority(login_nm) {
    let postBody = {
      "module": "KSB",
      "method": "USP_A02_0100",
      "type": "USP",
      "format":"json",
      "params": {
        login_nm:login_nm
      }
    };
    return this.httpClient.post(postBody, {
      isShowLoading: false,
      isAlterError: true
    });
  }

  getIPMAuthority() {
    let postBody = {
      "module": "OAServer",
      "method": "getIPMAuthority",
      "params": {

      }
    };
    return this.httpClient.post(postBody, {
      isShowLoading: false,
      isAlterError: true
    });
  }
}
